<html>
<head>
  <title>../vis.c</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<a href="../vis.c">download the original source code</a>.
<pre>
<a name="line1">  1</a> <font color="#444444">/* Save a structured n x n mesh of square elements on the unit square into a
<a name="line2">  2</a>    GLVis mesh file with the given name. */</font>
<a name="line3">  3</a> <strong>void</strong> <font color="#2040a0">GLVis_PrintGlobalSquareMesh</font><font color="4444FF">(</font><strong>const</strong> <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">meshfile</font>, <strong>int</strong> <font color="#2040a0">n</font><font color="4444FF">)</font>
<a name="line4">  4</a> <font color="4444FF"><strong>{</strong></font>
<a name="line5">  5</a>    <font color="#2040a0">FILE</font> <font color="4444FF">*</font><font color="#2040a0">file</font><font color="4444FF">;</font>
<a name="line6">  6</a> 
<a name="line7">  7</a>    <strong>int</strong> <font color="#2040a0">Dim</font> <font color="4444FF">=</font> <font color="#FF0000">2</font><font color="4444FF">;</font>
<a name="line8">  8</a>    <strong>int</strong> <font color="#2040a0">NumOfVertices</font> <font color="4444FF">=</font> <font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line9">  9</a>    <strong>int</strong> <font color="#2040a0">NumOfElements</font> <font color="4444FF">=</font> <font color="#2040a0">n</font><font color="4444FF">*</font><font color="#2040a0">n</font><font color="4444FF">;</font>
<a name="line10"> 10</a> 
<a name="line11"> 11</a>    <strong>int</strong> <font color="#2040a0">i</font>, <font color="#2040a0">j</font><font color="4444FF">;</font>
<a name="line12"> 12</a>    <strong>double</strong> <font color="#2040a0">x</font>, <font color="#2040a0">y</font><font color="4444FF">;</font>
<a name="line13"> 13</a>    <strong>double</strong> <font color="#2040a0">h</font> <font color="4444FF">=</font> <font color="#FF0000">1.0</font>/<font color="#2040a0">n</font><font color="4444FF">;</font>
<a name="line14"> 14</a> 
<a name="line15"> 15</a>    <strong>if</strong> <font color="4444FF">(</font><font color="4444FF">(</font><font color="#2040a0">file</font> <font color="4444FF">=</font> <font color="#2040a0">fopen</font><font color="4444FF">(</font><font color="#2040a0">meshfile</font>, <font color="#008000">&quot;w&quot;</font><font color="4444FF">)</font><font color="4444FF">)</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#2040a0">NULL</font><font color="4444FF">)</font>
<a name="line16"> 16</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line17"> 17</a>       <font color="#2040a0">printf</font><font color="4444FF">(</font><font color="#008000">&quot;Error: can't open output file %s<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">meshfile</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line18"> 18</a>       <font color="#2040a0">exit</font><font color="4444FF">(</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line19"> 19</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line20"> 20</a> 
<a name="line21"> 21</a>    <font color="#444444">/* mesh header */</font>
<a name="line22"> 22</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;MFEM mesh v1.0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line23"> 23</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>dimension<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line24"> 24</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line25"> 25</a> 
<a name="line26"> 26</a>    <font color="#444444">/* mesh elements */</font>
<a name="line27"> 27</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>elements<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line28"> 28</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfElements</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line29"> 29</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line30"> 30</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line31"> 31</a>          <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;1 3 %d %d %d %d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line32"> 32</a>                  <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line33"> 33</a> 
<a name="line34"> 34</a>    <font color="#444444">/* boundary will be generated by GLVis */</font>
<a name="line35"> 35</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>boundary<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line36"> 36</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line37"> 37</a> 
<a name="line38"> 38</a>    <font color="#444444">/* mesh vertices */</font>
<a name="line39"> 39</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>vertices<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line40"> 40</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfVertices</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line41"> 41</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line42"> 42</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line43"> 43</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line44"> 44</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line45"> 45</a>          <font color="#2040a0">x</font> <font color="4444FF">=</font> <font color="#2040a0">i</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line46"> 46</a>          <font color="#2040a0">y</font> <font color="4444FF">=</font> <font color="#2040a0">j</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line47"> 47</a>          <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%.14e %.14e<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">x</font>, <font color="#2040a0">y</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line48"> 48</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line49"> 49</a> 
<a name="line50"> 50</a>    <font color="#2040a0">fflush</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line51"> 51</a>    <font color="#2040a0">fclose</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line52"> 52</a> <font color="4444FF"><strong>}</strong></font>
<a name="line53"> 53</a> 
<a name="line54"> 54</a> <font color="#444444">/* Save a structured nx x ny mesh of square elements of size h, globally
<a name="line55"> 55</a>    translated by (x0,y0), into a GLVis mesh file with the given prefix. */</font>
<a name="line56"> 56</a> <strong>void</strong> <font color="#2040a0">GLVis_PrintLocalSquareMesh</font><font color="4444FF">(</font><strong>const</strong> <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">meshfile_prefix</font>, <strong>int</strong> <font color="#2040a0">nx</font>, <strong>int</strong> <font color="#2040a0">ny</font>,
<a name="line57"> 57</a>                                 <strong>double</strong> <font color="#2040a0">h</font>, <strong>double</strong> <font color="#2040a0">x0</font>, <strong>double</strong> <font color="#2040a0">y0</font>, <strong>int</strong> <font color="#2040a0">myid</font><font color="4444FF">)</font>
<a name="line58"> 58</a> <font color="4444FF"><strong>{</strong></font>
<a name="line59"> 59</a>    <font color="#2040a0">FILE</font> <font color="4444FF">*</font><font color="#2040a0">file</font><font color="4444FF">;</font>
<a name="line60"> 60</a>    <strong>char</strong> <font color="#2040a0">meshfile</font><font color="4444FF">[</font><font color="#FF0000">255</font><font color="4444FF">]</font><font color="4444FF">;</font>
<a name="line61"> 61</a> 
<a name="line62"> 62</a>    <strong>int</strong> <font color="#2040a0">Dim</font> <font color="4444FF">=</font> <font color="#FF0000">2</font><font color="4444FF">;</font>
<a name="line63"> 63</a>    <strong>int</strong> <font color="#2040a0">NumOfVertices</font> <font color="4444FF">=</font> <font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line64"> 64</a>    <strong>int</strong> <font color="#2040a0">NumOfElements</font> <font color="4444FF">=</font> <font color="#2040a0">nx</font><font color="4444FF">*</font><font color="#2040a0">ny</font><font color="4444FF">;</font>
<a name="line65"> 65</a> 
<a name="line66"> 66</a>    <strong>int</strong> <font color="#2040a0">i</font>, <font color="#2040a0">j</font><font color="4444FF">;</font>
<a name="line67"> 67</a>    <strong>double</strong> <font color="#2040a0">x</font>, <font color="#2040a0">y</font><font color="4444FF">;</font>
<a name="line68"> 68</a> 
<a name="line69"> 69</a>    <font color="#2040a0">sprintf</font><font color="4444FF">(</font><font color="#2040a0">meshfile</font>, <font color="#008000">&quot;%s.%06d&quot;</font>, <font color="#2040a0">meshfile_prefix</font>, <font color="#2040a0">myid</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line70"> 70</a>    <strong>if</strong> <font color="4444FF">(</font><font color="4444FF">(</font><font color="#2040a0">file</font> <font color="4444FF">=</font> <font color="#2040a0">fopen</font><font color="4444FF">(</font><font color="#2040a0">meshfile</font>, <font color="#008000">&quot;w&quot;</font><font color="4444FF">)</font><font color="4444FF">)</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#2040a0">NULL</font><font color="4444FF">)</font>
<a name="line71"> 71</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line72"> 72</a>       <font color="#2040a0">printf</font><font color="4444FF">(</font><font color="#008000">&quot;Error: can't open output file %s<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">meshfile</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line73"> 73</a>       <font color="#2040a0">exit</font><font color="4444FF">(</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line74"> 74</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line75"> 75</a> 
<a name="line76"> 76</a>    <font color="#444444">/* mesh header */</font>
<a name="line77"> 77</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;MFEM mesh v1.0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line78"> 78</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>dimension<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line79"> 79</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line80"> 80</a> 
<a name="line81"> 81</a>    <font color="#444444">/* mesh elements */</font>
<a name="line82"> 82</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>elements<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line83"> 83</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfElements</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line84"> 84</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">ny</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line85"> 85</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nx</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line86"> 86</a>          <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;1 3 %d %d %d %d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line87"> 87</a>                  <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line88"> 88</a> 
<a name="line89"> 89</a>    <font color="#444444">/* boundary will be generated by GLVis */</font>
<a name="line90"> 90</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>boundary<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line91"> 91</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line92"> 92</a> 
<a name="line93"> 93</a>    <font color="#444444">/* mesh vertices */</font>
<a name="line94"> 94</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>vertices<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line95"> 95</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfVertices</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line96"> 96</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line97"> 97</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line98"> 98</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line99"> 99</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line100">100</a>          <font color="#2040a0">x</font> <font color="4444FF">=</font> <font color="#2040a0">x0</font><font color="4444FF">+</font><font color="#2040a0">i</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line101">101</a>          <font color="#2040a0">y</font> <font color="4444FF">=</font> <font color="#2040a0">y0</font><font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line102">102</a>          <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%.14e %.14e<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">x</font>, <font color="#2040a0">y</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line103">103</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line104">104</a> 
<a name="line105">105</a>    <font color="#2040a0">fflush</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line106">106</a>    <font color="#2040a0">fclose</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line107">107</a> <font color="4444FF"><strong>}</strong></font>
<a name="line108">108</a> 
<a name="line109">109</a> <font color="#444444">/* Save a structured n x n mesh of gamma-angled rhombuses, globally rotated by
<a name="line110">110</a>    angle gamma*myid, into a GLVis mesh file with the given prefix. */</font>
<a name="line111">111</a> <strong>void</strong> <font color="#2040a0">GLVis_PrintLocalRhombusMesh</font><font color="4444FF">(</font><strong>const</strong> <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">meshfile_prefix</font>,
<a name="line112">112</a>                                  <strong>int</strong> <font color="#2040a0">n</font>, <strong>int</strong> <font color="#2040a0">myid</font>, <strong>double</strong> <font color="#2040a0">gamma</font><font color="4444FF">)</font>
<a name="line113">113</a> <font color="4444FF"><strong>{</strong></font>
<a name="line114">114</a>    <font color="#2040a0">FILE</font> <font color="4444FF">*</font><font color="#2040a0">file</font><font color="4444FF">;</font>
<a name="line115">115</a>    <strong>char</strong> <font color="#2040a0">meshfile</font><font color="4444FF">[</font><font color="#FF0000">255</font><font color="4444FF">]</font><font color="4444FF">;</font>
<a name="line116">116</a> 
<a name="line117">117</a>    <strong>int</strong> <font color="#2040a0">Dim</font> <font color="4444FF">=</font> <font color="#FF0000">2</font><font color="4444FF">;</font>
<a name="line118">118</a>    <strong>int</strong> <font color="#2040a0">NumOfVertices</font> <font color="4444FF">=</font> <font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line119">119</a>    <strong>int</strong> <font color="#2040a0">NumOfElements</font> <font color="4444FF">=</font> <font color="#2040a0">n</font><font color="4444FF">*</font><font color="#2040a0">n</font><font color="4444FF">;</font>
<a name="line120">120</a> 
<a name="line121">121</a>    <strong>int</strong> <font color="#2040a0">i</font>, <font color="#2040a0">j</font><font color="4444FF">;</font>
<a name="line122">122</a>    <strong>double</strong> <font color="#2040a0">x</font>, <font color="#2040a0">y</font><font color="4444FF">;</font>
<a name="line123">123</a>    <strong>double</strong> <font color="#2040a0">h</font> <font color="4444FF">=</font> <font color="#FF0000">1.0</font>/<font color="#2040a0">n</font><font color="4444FF">;</font>
<a name="line124">124</a> 
<a name="line125">125</a>    <strong>double</strong> <font color="#2040a0">rho</font> <font color="4444FF">=</font> <font color="#2040a0">gamma</font><font color="4444FF">*</font><font color="#2040a0">myid</font><font color="4444FF">;</font>
<a name="line126">126</a>    <strong>double</strong> <font color="#2040a0">sg</font>  <font color="4444FF">=</font> <font color="#2040a0">sin</font><font color="4444FF">(</font><font color="#2040a0">gamma</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line127">127</a>    <strong>double</strong> <font color="#2040a0">cg</font>  <font color="4444FF">=</font> <font color="#2040a0">cos</font><font color="4444FF">(</font><font color="#2040a0">gamma</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line128">128</a>    <strong>double</strong> <font color="#2040a0">sr</font>  <font color="4444FF">=</font> <font color="#2040a0">sin</font><font color="4444FF">(</font><font color="#2040a0">rho</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line129">129</a>    <strong>double</strong> <font color="#2040a0">cr</font>  <font color="4444FF">=</font> <font color="#2040a0">cos</font><font color="4444FF">(</font><font color="#2040a0">rho</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line130">130</a> 
<a name="line131">131</a>    <font color="#2040a0">sprintf</font><font color="4444FF">(</font><font color="#2040a0">meshfile</font>, <font color="#008000">&quot;%s.%06d&quot;</font>, <font color="#2040a0">meshfile_prefix</font>, <font color="#2040a0">myid</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line132">132</a>    <strong>if</strong> <font color="4444FF">(</font><font color="4444FF">(</font><font color="#2040a0">file</font> <font color="4444FF">=</font> <font color="#2040a0">fopen</font><font color="4444FF">(</font><font color="#2040a0">meshfile</font>, <font color="#008000">&quot;w&quot;</font><font color="4444FF">)</font><font color="4444FF">)</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#2040a0">NULL</font><font color="4444FF">)</font>
<a name="line133">133</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line134">134</a>       <font color="#2040a0">printf</font><font color="4444FF">(</font><font color="#008000">&quot;Error: can't open output file %s<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">meshfile</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line135">135</a>       <font color="#2040a0">exit</font><font color="4444FF">(</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line136">136</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line137">137</a> 
<a name="line138">138</a>    <font color="#444444">/* mesh header */</font>
<a name="line139">139</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;MFEM mesh v1.0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line140">140</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>dimension<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line141">141</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line142">142</a> 
<a name="line143">143</a>    <font color="#444444">/* mesh elements */</font>
<a name="line144">144</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>elements<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line145">145</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfElements</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line146">146</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line147">147</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line148">148</a>          <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;1 3 %d %d %d %d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line149">149</a>                  <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>, <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line150">150</a> 
<a name="line151">151</a>    <font color="#444444">/* boundary will be generated by GLVis */</font>
<a name="line152">152</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>boundary<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line153">153</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line154">154</a> 
<a name="line155">155</a>    <font color="#444444">/* mesh vertices */</font>
<a name="line156">156</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>vertices<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line157">157</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfVertices</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line158">158</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line159">159</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line160">160</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line161">161</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line162">162</a>          <font color="#2040a0">x</font> <font color="4444FF">=</font> <font color="#2040a0">i</font><font color="4444FF">*</font><font color="#2040a0">h</font> <font color="4444FF">+</font> <font color="#2040a0">cg</font><font color="4444FF">*</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line163">163</a>          <font color="#2040a0">y</font> <font color="4444FF">=</font> <font color="#2040a0">sg</font><font color="4444FF">*</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line164">164</a>          <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%.14e %.14e<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">cr</font><font color="4444FF">*</font><font color="#2040a0">x</font> <font color="4444FF">-</font> <font color="#2040a0">sr</font><font color="4444FF">*</font><font color="#2040a0">y</font>, <font color="#2040a0">sr</font><font color="4444FF">*</font><font color="#2040a0">x</font> <font color="4444FF">+</font> <font color="#2040a0">cr</font><font color="4444FF">*</font><font color="#2040a0">y</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line165">165</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line166">166</a> 
<a name="line167">167</a>    <font color="#2040a0">fflush</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line168">168</a>    <font color="#2040a0">fclose</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line169">169</a> <font color="4444FF"><strong>}</strong></font>
<a name="line170">170</a> 
<a name="line171">171</a> <font color="#444444">/* Save a structured nx x ny x nz mesh of cubic elements of size h, globally
<a name="line172">172</a>    translated by (x0,y0,z0), into a GLVis mesh file with the given prefix. */</font>
<a name="line173">173</a> <strong>void</strong> <font color="#2040a0">GLVis_PrintLocalCubicMesh</font><font color="4444FF">(</font><strong>const</strong> <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">meshfile_prefix</font>,
<a name="line174">174</a>                                <strong>int</strong> <font color="#2040a0">nx</font>, <strong>int</strong> <font color="#2040a0">ny</font>, <strong>int</strong> <font color="#2040a0">nz</font>, <strong>double</strong> <font color="#2040a0">h</font>,
<a name="line175">175</a>                                <strong>double</strong> <font color="#2040a0">x0</font>, <strong>double</strong> <font color="#2040a0">y0</font>, <strong>double</strong> <font color="#2040a0">z0</font>, <strong>int</strong> <font color="#2040a0">myid</font><font color="4444FF">)</font>
<a name="line176">176</a> <font color="4444FF"><strong>{</strong></font>
<a name="line177">177</a>    <font color="#2040a0">FILE</font> <font color="4444FF">*</font><font color="#2040a0">file</font><font color="4444FF">;</font>
<a name="line178">178</a>    <strong>char</strong> <font color="#2040a0">meshfile</font><font color="4444FF">[</font><font color="#FF0000">255</font><font color="4444FF">]</font><font color="4444FF">;</font>
<a name="line179">179</a> 
<a name="line180">180</a>    <strong>int</strong> <font color="#2040a0">Dim</font> <font color="4444FF">=</font> <font color="#FF0000">3</font><font color="4444FF">;</font>
<a name="line181">181</a>    <strong>int</strong> <font color="#2040a0">NumOfVertices</font> <font color="4444FF">=</font> <font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nz</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line182">182</a>    <strong>int</strong> <font color="#2040a0">NumOfElements</font> <font color="4444FF">=</font> <font color="#2040a0">nx</font><font color="4444FF">*</font><font color="#2040a0">ny</font><font color="4444FF">*</font><font color="#2040a0">nz</font><font color="4444FF">;</font>
<a name="line183">183</a> 
<a name="line184">184</a>    <strong>int</strong> <font color="#2040a0">i</font>, <font color="#2040a0">j</font>, <font color="#2040a0">k</font><font color="4444FF">;</font>
<a name="line185">185</a>    <strong>double</strong> <font color="#2040a0">x</font>, <font color="#2040a0">y</font>, <font color="#2040a0">z</font><font color="4444FF">;</font>
<a name="line186">186</a> 
<a name="line187">187</a>    <font color="#2040a0">sprintf</font><font color="4444FF">(</font><font color="#2040a0">meshfile</font>, <font color="#008000">&quot;%s.%06d&quot;</font>, <font color="#2040a0">meshfile_prefix</font>, <font color="#2040a0">myid</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line188">188</a>    <strong>if</strong> <font color="4444FF">(</font><font color="4444FF">(</font><font color="#2040a0">file</font> <font color="4444FF">=</font> <font color="#2040a0">fopen</font><font color="4444FF">(</font><font color="#2040a0">meshfile</font>, <font color="#008000">&quot;w&quot;</font><font color="4444FF">)</font><font color="4444FF">)</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#2040a0">NULL</font><font color="4444FF">)</font>
<a name="line189">189</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line190">190</a>       <font color="#2040a0">printf</font><font color="4444FF">(</font><font color="#008000">&quot;Error: can't open output file %s<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">meshfile</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line191">191</a>       <font color="#2040a0">exit</font><font color="4444FF">(</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line192">192</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line193">193</a> 
<a name="line194">194</a>    <font color="#444444">/* mesh header */</font>
<a name="line195">195</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;MFEM mesh v1.0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line196">196</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>dimension<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line197">197</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line198">198</a> 
<a name="line199">199</a>    <font color="#444444">/* mesh elements */</font>
<a name="line200">200</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>elements<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line201">201</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfElements</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line202">202</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">k</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">k</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nz</font><font color="4444FF">;</font> <font color="#2040a0">k</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line203">203</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">ny</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line204">204</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nx</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line205">205</a>             <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;1 5 %d %d %d %d %d %d %d %d<font color="#77dd77">\n</font>&quot;</font>,
<a name="line206">206</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="#2040a0">k</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line207">207</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="#2040a0">k</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line208">208</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="#2040a0">k</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line209">209</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="#2040a0">k</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line210">210</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">k</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line211">211</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">k</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line212">212</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="#FF0000">1</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">k</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,
<a name="line213">213</a>                     <font color="#2040a0">i</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">j</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="4444FF">(</font><font color="#2040a0">k</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line214">214</a> 
<a name="line215">215</a>    <font color="#444444">/* boundary will be generated by GLVis */</font>
<a name="line216">216</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>boundary<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line217">217</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;0<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line218">218</a> 
<a name="line219">219</a>    <font color="#444444">/* mesh vertices */</font>
<a name="line220">220</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;<font color="#77dd77">\n</font>vertices<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line221">221</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">NumOfVertices</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line222">222</a>    <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%d<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">Dim</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line223">223</a>    <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">k</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">k</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nz</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">k</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line224">224</a>       <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">ny</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line225">225</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nx</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line226">226</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line227">227</a>             <font color="#2040a0">x</font> <font color="4444FF">=</font> <font color="#2040a0">x0</font><font color="4444FF">+</font><font color="#2040a0">i</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line228">228</a>             <font color="#2040a0">y</font> <font color="4444FF">=</font> <font color="#2040a0">y0</font><font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line229">229</a>             <font color="#2040a0">z</font> <font color="4444FF">=</font> <font color="#2040a0">z0</font><font color="4444FF">+</font><font color="#2040a0">k</font><font color="4444FF">*</font><font color="#2040a0">h</font><font color="4444FF">;</font>
<a name="line230">230</a>             <font color="#2040a0">fprintf</font><font color="4444FF">(</font><font color="#2040a0">file</font>, <font color="#008000">&quot;%.14e %.14e %.14e<font color="#77dd77">\n</font>&quot;</font>, <font color="#2040a0">x</font>, <font color="#2040a0">y</font>, <font color="#2040a0">z</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line231">231</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line232">232</a> 
<a name="line233">233</a>    <font color="#2040a0">fflush</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line234">234</a>    <font color="#2040a0">fclose</font><font color="4444FF">(</font><font color="#2040a0">file</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line235">235</a> <font color="4444FF"><strong>}</strong></font>

</pre>
<hr>
syntax highlighted by <a href="http://www.palfrader.org/code2html">Code2HTML</a>, v. 0.9.1
</body>
</html>
